/**
 * This software was produced for the U. S. Government
 * under Contract No. FA8721-09-C-0002, and is
 * subject to the Rights in Noncommercial Computer Software
 * and Noncommercial Computer Software Documentation Clause
 * (DFARS) 252.227-7014 (JUN 1995)
 * 
 * (c) 2009 The MITRE Corporation. All Rights Reserved.
 *
 * SPMIF to OPNET Translator
 * Author: EWALTERS
 * Created: 3:51:17 PM, Nov 2, 2007
 * MITRE Corporation
 */
package com.mitre.spmif2opnet.analysis;


/**
 * This class transforms the S-PMIF priorities to OPNET ones
 *  by scaling using a factor.
 */
public class ScaledPriorities extends Priorities {
	
	/**
	 * Default constructor
	 * @param type the type
	 */
	public ScaledPriorities(PriorityType type) {
		super(type);
	}
	
	/** 
	 * Do a straight scaling from S-PMIF Priorities to OPNET ones
	 * Yes, this could result in duplicates
	 */
	@Override
	public void calculate() {
		for (String id : this._spmif_priorities.keySet()) {
			Integer val = this._spmif_priorities.get(id);
			if (val == null) {
				val = new Integer(-1);
			} else {
				Double d = new Double(val);
				val = new Double(d.doubleValue() * (_opnet_scale / _spmif_scale)).intValue(); 
			}
			this._opnet_priorities.put(id, val);
		}
		this._processed = true;
	}

}
